package net.thelostlands.plugins.thelostfortress;


import org.bukkit.block.Block;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityExplodeEvent;

/**
 *
 * @author fabio
 */
public class ListenToEntity implements Listener {

    @EventHandler
    public void onEntityExplode(EntityExplodeEvent event) {
        Block b = event.getLocation().getBlock();
        if ((b.getWorld().getName().compareTo(Main.mondo) == 0 && b.getY() > 60 && Main.area.creeperFind(b.getX(), b.getY(), b.getZ()))) {
            event.setCancelled(true);
        }

    }
    
    @EventHandler
    public void onEntityDamage(EntityDamageEvent event){
        if(Main.area.find(event.getEntity().getLocation())){
            if(!Main.guerraAttiva) {
                event.setCancelled(true);
            }
        }
    }
}
